
from langchain.chat_models import init_chat_model
from langchain_community.embeddings import DashScopeEmbeddings
from .settings import *


def get_model(api_key, api_base='https://dashscope.aliyuncs.com/compatible-mode/v1', model='deepseek-chat'):

    model = init_chat_model(
        model=model,
        api_key=api_key,
        api_base=api_base,
        temperature=0,
    )
    return model


def get_embeddings():
    embeddings = DashScopeEmbeddings(
        model=CNF_DATA['agent']['embedding_model'],
        dashscope_api_key=CNF_DATA['agent']['embedding_api_key'],
    )
    return embeddings


if __name__ == '__main__':

    api_key = ''
    api_base = 'https://dashscope.aliyuncs.com/compatible-mode/v1'

    model = get_model(api_key, api_base, model='deepseek-v3.1')
    messages = [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "你是谁？"}]
    response = model.invoke(messages)
    print(response.json())


